// import axios from 'axios'
// axios.defaults.baseURL = "http://www.tangxiaoyang.vip:8888/api/v2/";
// export function userLogin(params={}){
//     return axios.post("login",params)
// }

import request from '../util/request.js'

export function userLogin(data = {}) {
    return request({
        url:"/login",
        method:"POST",
        data:data
    });
}

export function loadUserList(params = {}) {
    return request({
        url:"/users",
        method:"GET",
        params:params
    });
}

export function loadUserById(userId) {
    return request({
        url:`/users/${userId}`,
        method:"GET",
    });
}

export function changeUserState(userId,type) {
    return request({
        url:`/users/${userId}/state/${type}`,
        method:"PUT"
    });
}

export function removeUser(userId) {
    return request({
        url:`/users/${userId}`,
        method:"DELETE"
    });
}

export function modfilyUser(userId,user={}) {
    return request({
        url:`/users/${userId}`,
        method:"PUT",
		data:user
    });
}

export function settingUserRole(userId,rid) {
    return request({
        url:`/users/${userId}/role`,
        method:"PUT",
		data:{
			rid:rid
		}
    });
}

export function addUser(data={}) {
    return request({
        url:`/users`,
        method:"POST",
		data:data
    });
}